package com.time.sky.mapper;

import com.time.sky.entity.HM;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface HmMapper {
    @Select("SELECT * FROM HM h LEFT JOIN uinfo u ON h.uid=u.uid left join binfo b on h.bid = b.bid")
    List<HM> selectHMList();
    @Insert("insert into HM(fwzt,waterb,watersite,dbsite,realarea,sfarea,payinfo,paytime,buyftime,bid,uid) " +
            "values(#{fwzt},#{waterb},#{watersite},#{dbsite},#{realarea},#{sfarea},#{payinfo},#{paytime},#{buyftime},#{bid},#{uid})")
    void addHM(HM hm);
    @Delete("delete from HM where hid=#{hid}")
    void deleteHM(int hid);
    @Select("SELECT * FROM HM  where hid=#{hid}")
    HM getHMById(int hid);
    @Update("update HM set fwzt=#{fwzt},waterb=#{waterb},watersite=#{watersite},dbsite=#{dbsite},realarea=#{realarea},sfarea=#{sfarea},payinfo=#{payinfo},paytime=#{paytime},buyftime=#{buyftime},bid=#{bid},uid=#{uid} where hid=#{hid}")
    void updateHM(HM hm);

    @Delete("<script>" +
            "delete from HM where hid in " +
            "<foreach collection='list' item='hid' open='(' separator=',' close=')'>#{hid}</foreach> " +
            "</script>")
    void deleteBatch(List<Integer> idList);

    List<HM> findByName(HM hm);
    //模糊查询有待改进
    /* @Select({"select * from HM where concat(name,dengji_time) like '%' || 'search_name' || '%' "})
     *//*public List<HM> selectMohu(@Param("search_name") String search_name);*//*
    List<HM> findByName(HM hm);*/

    @Select("select count(*) from HM")
    int getRowCount();
}
